package com.itheima.chapter08.set.TreeSet;

public class Studentcase2 implements Comparable<Studentcase2> {
    private String name;
    private  int age;
    private  double Chinese;
    private  double Math;
    private  double English;

    public Studentcase2() {
    }

    public Studentcase2(String name, int age, double chinese, double math, double english) {
        this.name = name;
        this.age = age;
        Chinese = chinese;
        Math = math;
        English = english;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getChinese() {
        return Chinese;
    }

    public void setChinese(double chinese) {
        Chinese = chinese;
    }

    public double getMath() {
        return Math;
    }

    public void setMath(double math) {
        Math = math;
    }

    public double getEnglish() {
        return English;
    }

    public void setEnglish(double english) {
        English = english;
    }

    @Override
    public String toString() {
        return "Studentcase2{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", Chinese=" + Chinese +
                ", Math=" + Math +
                ", English=" + English +
                '}';
    }
    public double getSum(){
        return Chinese+Math+English;
    }
    @Override
    public int compareTo(Studentcase2 o) {

        double result = this.getSum() - o.getSum();
        result =result==0?this.getChinese()-o.getChinese():result;
        result =result==0?this.getMath()-o.getMath():result;
        result =result==0?this.getEnglish()-o.getEnglish():result;
        result =result==0?this.getName().compareTo(o.getName()):result;

        return (int)result;
    }
}
